# ----------------------------------------------------------------------
#  Paper: Party Competition and Cooperation Shape Affective Polarization
#  Last updated: February 2021
#  Purpose: Download raw data files from INES
#  Outputs: 7 Unzipped files of raw INES data in director "Raw Data/INES_Downloaded"
#  Machine: Chagai's macbook pro
# ----------------------------------------------------------------------

# This script downloads data from seven waves of INES elections studies 
# 2001, 2003, 2006, 2009, 2013, 2015, 2019. Note that the current version of the 
# 2019 survey include the September elections which were not used for our anlysis. 
# If preferred, data can be downloaded directly from:
# https://www.tau.ac.il/~ines

#Make sure to change working directory (/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1)

# Download 2019 INES
download.file("https://www.tau.ac.il/~ines/files/2019.zip",
              "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2019.zip")
unzip("/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2019.zip", 
exdir = "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2019",
      junkpaths = T, overwrite = T)




# Download 2015 INES
download.file("https://www.tau.ac.il/~ines/files/2015.zip",
              "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2015.zip")
unzip("/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2015.zip", 
      exdir = "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2015",
      junkpaths = T, overwrite = T)


# Download 2013 INES
download.file("https://www.tau.ac.il/~ines/files/2013.zip",
              "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2013.zip")
unzip("/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2013.zip", 
      exdir = "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2013",
      junkpaths = T, overwrite = T)



# Download 2009 INES
download.file("https://www.tau.ac.il/~ines/files/2009.zip",
              "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2009.zip")
unzip("/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2009.zip", 
      exdir = "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2009",
      junkpaths = T, overwrite = T)




# Download 2006 INES
download.file("https://www.tau.ac.il/~ines/files/2006.zip",
              "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2006.zip")
unzip("/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2006.zip", 
      exdir = "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2006",
      junkpaths = T, overwrite = T)


# Download 2003 INES
download.file("https://www.tau.ac.il/~ines/files/2003.zip",
              "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2003.zip")
unzip("/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2003.zip", 
      exdir = "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2003",
      junkpaths = T, overwrite = T)


# Download 2001 INES
download.file("https://www.tau.ac.il/~ines/files/2001.zip",
              "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2001.zip")
unzip("/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2001.zip", 
      exdir = "/Users/chagaiweiss/Dropbox/Research Projects/Affective Polarization/Replication CPS 1/Raw Data/INES/2001",
      junkpaths = T, overwrite = T)


